import { request } from './request'
import type { Job, PaginatedResponse } from '@/types'

// 获取职位列表
export const getJobs = (params: {
  page: number
  page_size: number
  location?: string
  status?: number
}) => {
  return request<PaginatedResponse<Job>>({
    url: '/admin/jobs',
    method: 'get',
    params
  })
}

// 获取职位详情
export const getJob = (id: number) => {
  return request<Job>({
    url: `/admin/jobs/${id}`,
    method: 'get'
  })
}

// 创建职位
export const createJob = (data: Partial<Job>) => {
  return request<Job>({
    url: '/admin/jobs',
    method: 'post',
    data
  })
}

// 更新职位
export const updateJob = (id: number, data: Partial<Job>) => {
  return request<Job>({
    url: `/admin/jobs/${id}`,
    method: 'put',
    data
  })
}

// 删除职位
export const deleteJob = (id: number) => {
  return request({
    url: `/admin/jobs/${id}`,
    method: 'delete'
  })
}

